package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.BillManageInfo;
import com.ruoyi.property.service.IBillManageInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账单催缴Controller
 * 
 * @author sux
 * @date 2021-06-30
 */
@Controller
@RequestMapping("/property/billManageInfo")
public class BillManageInfoController extends BaseController
{
    private String prefix = "property/billManageInfo";

    @Autowired
    private IBillManageInfoService billManageInfoService;

    @RequiresPermissions("property:billManageInfo:view")
    @GetMapping()
    public String billManageInfo()
    {
        return prefix + "/billManageInfo";
    }

    /**
     * 查询账单催缴列表
     */
    @RequiresPermissions("property:billManageInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BillManageInfo billManageInfo)
    {
        startPage();
        List<BillManageInfo> list = billManageInfoService.selectBillManageInfoList(billManageInfo);
        return getDataTable(list);
    }

    /**
     * 导出账单催缴列表
     */
    @RequiresPermissions("property:billManageInfo:export")
    @Log(title = "账单催缴", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BillManageInfo billManageInfo)
    {
        List<BillManageInfo> list = billManageInfoService.selectBillManageInfoList(billManageInfo);
        ExcelUtil<BillManageInfo> util = new ExcelUtil<BillManageInfo>(BillManageInfo.class);
        return util.exportExcel(list, "billManageInfo");
    }

    /**
     * 新增账单催缴
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存账单催缴
     */
    @RequiresPermissions("property:billManageInfo:add")
    @Log(title = "账单催缴", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BillManageInfo billManageInfo)
    {
        return toAjax(billManageInfoService.insertBillManageInfo(billManageInfo));
    }

    /**
     * 修改账单催缴
     */
    @GetMapping("/edit/{billId}")
    public String edit(@PathVariable("billId") Long billId, ModelMap mmap)
    {
        BillManageInfo billManageInfo = billManageInfoService.selectBillManageInfoById(billId);
        mmap.put("billManageInfo", billManageInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存账单催缴
     */
    @RequiresPermissions("property:billManageInfo:edit")
    @Log(title = "账单催缴", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BillManageInfo billManageInfo)
    {
        return toAjax(billManageInfoService.updateBillManageInfo(billManageInfo));
    }

    /**
     * 删除账单催缴
     */
    @RequiresPermissions("property:billManageInfo:remove")
    @Log(title = "账单催缴", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(billManageInfoService.deleteBillManageInfoByIds(ids));
    }
}
